#include<stdio.h> 
#include<stdlib.h>
#include<unistd.h> 
#include<string.h>
#include<sys/types.h>
#include<sys/wait.h>

int main()
{
  //FILE* fp = fopen("./log.txt","w");
  
  FILE* fp = fopen("./log.txt","r");//读取内容
  if(NULL == fp){
    perror("fopen");
    return 1;
  }
  char buff[128];
  while(fgets(buff,sizeof(buff),fp))
  {
    //从fp中最大读取sizeof(buff)个字符写入buff
    printf("%s",buff);
  }
  if(feof(fp)){
    printf("fgets quit normal!\n");
  }
  else{
    printf("fgets quit unnormal!\n");
  }

 // int cnt = 10;
 // while(cnt--)
 // {
 //   const char* msg1 = "hello stdout\n";
 //   const char* msg2 = "hello file\n";
 //   fputs(msg1, stdout);
 //   fputs(msg2, fp);
 // }
 fclose(fp);
}
